package com.sasis.util;
import java.util.ArrayList;
import java.util.List;
public class PageUtil{ 
 public static PageList queryForPageList(PageRequest pageRequest,List list) {
	    
		int indx = pageRequest.getPageIndex();
		if(0==indx)indx = 1;
		int skip = (indx - 1) * pageRequest.getPageSize();
		int max = pageRequest.getPageSize();
		List pageList = new ArrayList(); 
		//int frmIndx = list.size()-skip*max;
		int maxIndx = max*indx;
		if(maxIndx>list.size()) maxIndx = list.size();
		for(int i=skip;i<maxIndx;i++){
			pageList.add(list.get(i));
		} 
		return  new ArrayPageList(pageList, list.size(), pageRequest);
	 
    }
}